Imports ACFramework

Public Class PSeleccionar

#Region " Variables "
   Private m_listaC1 As List(Of Lista)
   Private m_listaDGV As List(Of Lista)
   Private bs_listaC1 As BindingSource
   Private bs_listaDGV As BindingSource
   Private bs_listaFiltrada As BindingSource
   Private m_c1 As Boolean
#End Region

#Region " Propiedades "

#End Region

#Region " Constructores "
   Public Sub New()

      ' This call is required by the Windows Form Designer.
      InitializeComponent()
      NsTextBoxNumerico1.Text = 100
      ' Add any initialization after the InitializeComponent() call.

   End Sub
#End Region

#Region " Metodos "

#End Region

#Region " Metodos de Controles"
   Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
      Try
         m_listaC1 = New List(Of Lista)
         m_listaDGV = New List(Of Lista)
         Dim i As Integer = CType(NsTextBoxNumerico1.Text, Integer)
         For index As Integer = 1 To i
            m_listaC1.Add(New Lista(IIf(CheckBox1.Checked, (Int(Rnd() * i)).ToString(), index.ToString()), "Descripcion: " & index.ToString()))
            m_listaDGV.Add(New Lista(IIf(CheckBox1.Checked, (Int(Rnd() * i)).ToString(), index.ToString()), "Descripcion: " & index.ToString()))
         Next
         bs_listaC1 = New BindingSource()
         bs_listaDGV = New BindingSource()
         bs_listaC1.DataSource = m_listaC1
         bs_listaDGV.DataSource = m_listaDGV
         DataGridView1.DataSource = bs_listaDGV
         C1FlexGrid1.DataSource = bs_listaC1
         BindingNavigator1.BindingSource = bs_listaC1
         BindingNavigator2.BindingSource = bs_listaDGV
         C1FlexGrid1.Cols(0).Width = 20
      Catch ex As Exception
         Throw ex
      End Try
   End Sub


#End Region

   Private Sub C1FlexGrid1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles C1FlexGrid1.MouseClick
      Try
         If e.Button = Windows.Forms.MouseButtons.Right Then
            If C1FlexGrid1.Rows.Count > 1 Then
               AccmsSeleccionarC11.ACMostrar(C1FlexGrid1, Windows.Forms.Cursor.Position, "Seleccionar")
               m_c1 = True
            End If
         End If
      Catch ex As Exception
         ACControles.ACDialogos.MostrarMensajeError("Error: " & Me.Text, "Ha ocurrido un error en el proceso seleccionar", ex)
      End Try
   End Sub

   Private Sub DataGridView1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseClick
      Try
         If e.Button = Windows.Forms.MouseButtons.Right Then
            If DataGridView1.Rows.Count > 1 Then
               AccmsSeleccionarC11.ACMostrar(DataGridView1, Windows.Forms.Cursor.Position, "Seleccionar")
               m_c1 = False
            End If
         End If
      Catch ex As Exception
         ACControles.ACDialogos.MostrarMensajeError("Error: " & Me.Text, "Ha ocurrido un error en el proceso seleccionar", ex)
      End Try
   End Sub

   Private Sub NscmsSeleccionar1_NSCMSeleccionar_Click(ByVal sender As ACControles.ACCMSSeleccionar.ACSeleccionar, ByVal e As System.EventArgs)
      If m_c1 Then
         TextBox1.Text = sender.ToString()
      Else
         TextBox2.Text = sender.ToString()
      End If
   End Sub
End Class